package com.example.app.components


import android.util.Log
import androidx.compose.foundation.layout.Column
import androidx.compose.material.Checkbox
import androidx.compose.runtime.*
import androidx.compose.ui.tooling.preview.Preview

@Composable
fun CheckedSample() {
//    var check by remember {
//        mutableStateOf(true)
//    }
//    Checkbox(checked = check, onCheckedChange = {
//        check = it
//    })

    var checkList by remember {
        mutableStateOf(listOf(false, true, true))
    }
    Column() {
        checkList.forEachIndexed { index, b ->
            Checkbox(checked = b, onCheckedChange = {
                Log.i("====", "$index")
                checkList = checkList.mapIndexed { indexs, s ->
                    if (index == indexs) {
                        !s
                    } else {
                        s
                    }
                }
            })
        }
    }
}

@Preview(
    showSystemUi = true
)
@Composable
fun CheckedSamplePreview() {
    CheckedSample()
}

